#
from typing import Dict, List
import logging
from dbs.mysql_engine import MysqlEngine

# 配置日志记录
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)

class QstnDao(object):
    def __init__(self):
        self.name = 'dbs.qstn_dao.QstnDao'
    
    @staticmethod
    def add_qstn(params:Dict = {}) -> None:
        sql_params = []
        sql_params.append(params['qstn_title'])
        sql_params.append(params['notes'])
        sql = 'INSERT INTO z_qstn(qstn_title, notes) VALUES(%s, %s)'
        qstn_id = MysqlEngine.add_rec(sql, sql_params)
        print(f'###### 问题编号：{qstn_id}; v0.0.1 ???????????')

    @staticmethod
    def get_qstn_by_id(qstn_id) -> List:
        sql = 'SELECT qstn_title, notes FROM z_qstn WHERE qstn_id=%s'
        params = (qstn_id)
        recs = MysqlEngine.query(sql, params)
        print(f'recs: {type(recs)}; ')
        qstn_rec = None
        for rec in recs:
            qstn_rec = rec
        return qstn_rec